/*******************************************
 * Copyright 2007 Aphrodite Framework for javaME .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Email : owner@aphroditeme.dev.java.net
 * Contributors:
 *     Kent Elton - initial API and implementation
 *******************************************/

package com.aphrodite.xml.wap;

/**
 * Attribute class, used by both kDom and the pullparser. The instances of this
 * class are immutable. This restriction allows manipulation aware element
 * implementations without needing to care about hidden changes in attributes.
 */

class Attribute {

	String namespace;
	String name;
	String value;

	/**
	 * Creates a new Attribute instance with the given name and value. The
	 * namespace is set to "".
	 */

	Attribute(String name, String value) {
		this.namespace = "";
		this.name = name;
		this.value = value;
	}

	/**
	 * creates a new Attribute with the given namespace, name and value
	 */

	Attribute(String namespace, String name, String value) {
		this.namespace = namespace == null ? "" : namespace;
		this.name = name;
		this.value = value;
	}

	/** returns the string value of the attribute */

	public String getValue() {
		return value;
	}

	/** returns the name of the attribute */

	public String getName() {
		return name;
	}

	/** returns the namespace of the attribute */

	public String getNamespace() {
		return namespace;
	}

	public String toString() {
		return (!namespace.equals("") ? ("{" + namespace + "}" + name) : name) + "=\"" + value + "\"";
	}
}
